package com.lark.mapper;


import com.lark.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {

    @Select("select * from l_user where username=#{username},password=#{password}")
    public User findByUsernameAndPassword(String username, String password);

    @Select("select * from l_user")
    public List<User> findAll();

    @Insert("insert into l_user values(#{id},#{username},#{password},#{email},#{telephone},#{registertime},#{photo},#{statu})")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    public Long insert(User user);

    @Insert("insert into l_user_role values(#{userId},#{roleId})")
    public void saveUserRoleRel(@Param("userId") Long userId, @Param("roleId") Long roleId);

    @Delete("delete from l_user where id=#{id}")
    public void delete(Long userId);

    @Delete("delete from l_user_role where userId=#{userId}")
    public void deleteUserRoleRel(Long userId);

    @Select("select * from l_user where id=#{id}")
    public User findById(Long id);
}
